using Awaiter;
using YesPlayLove.Classes;
using YesPlayLove.Clusters;
using YoshiBase.Classes;

namespace YoshiFlowMain
{
    //[IgnoreNamespace] Don't use because full class name is used in Master.cs to find this class
    public sealed class MagneticListPage : YoshiPage
    {
        private MagBubble _cluster;

        public MagneticListPage()
        {
            new Await()
                .AddAw(BasicBuildAw, MagneticListPageTheme.PageTitle)
                .Commit();
        }

        public override void Destroy()
        {
            if (_cluster != null)
                _cluster.Destroy();
        }

        public override void RefreshAw(Await awp)
        {
            new Await()
                .AddDx(
                    delegate(Await aw)
                    {
                        Destroy();
                        _cluster = new MagBubble(aw);
                        _cluster.Element.AppendTo(PageCluster);
                    }
                )
                .Commit(awp);
        }

        public override void UpdatePage(PageUpdate pu)
        {
            TopBar.UpdatePage(pu);
        }
    }
}